﻿<ul>
    <li>有 <code>ValidateForm</code> 组件时，会根据绑定字段查找 <code>DisplayName</code> 标签自动显示标签</li>
    <li>无 <code>ValidateForm</code> 组件时，根据 <code>ShowLabel</code> 属性值，显示 <code>DisplayText</code> 设置的文字</li>
</ul>
<Divider Text="有 ValidatoeForm 时双向绑定" Alignment="Alignment.Left" style="margin: 2rem 0;"></Divider>
<ValidateForm class="form-inline" Model="@Model">
    <div class="row">
        <div class="form-group col-12">
            <Select TItem="string" Color="Color.Primary" Items="@Items" @bind-Value="@Model.Name"></Select>
        </div>
    </div>
</ValidateForm>
<Divider Text="无 ValidatoeForm 时双向绑定" Alignment="Alignment.Left" style="margin: 2rem 0;"></Divider>
<div class="form-inline">
    <div class="row">
        <div class="form-group col-12">
            <Select TItem="string" Color="Color.Primary" Items="@Items" @bind-Value="@Model.Name"></Select>
        </div>
    </div>
</div>
<Divider Text="设置 DisplayText" Alignment="Alignment.Left" style="margin: 2rem 0;"></Divider>
<div class="form-inline">
    <div class="row">
        <div class="form-group col-12">
            <Select TItem="string" Color="Color.Primary" Items="@Items" @bind-Value="@Model.Name" DisplayText="自定义城市"></Select>
        </div>
    </div>
</div>

@code {
    /// <summary>
    /// 
    /// </summary>
    private Foo Model { get; set; } = new Foo();

    /// <summary>
    /// 获得 默认数据集合
    /// </summary>
    private readonly IEnumerable<SelectedItem> Items = new SelectedItem[]
    {
        new SelectedItem ("Beijing", "北京"),
        new SelectedItem ("Shanghai", "上海") { Active = true }
    };

    internal class Foo
    {
        /// <summary>
        /// 
        /// </summary>
        [DisplayName("城市名称")]
        public string Name { get; set; } = "Shanghai";
    }
}
